import pandas as pd
import pymysql
import numpy as np


def concreat_dateframe(table_name):
    db = pymysql.connect('localhost', 'root', 'minicooper', 'stock_info', charset="utf8")
    cursor = db.cursor()

    df = pd.read_sql("SELECT * FROM {0} WHERE DATE BETWEEN '1996-06-23' AND '1996-07-02'".format(table_name),con=db).set_index('DATE')



    db.close()
    return df












if __name__ == '__main__':
    sh0000001_df = concreat_dateframe('sh000001')
    sh0000010_df = concreat_dateframe('sh000010')
    df = pd.DataFrame()

    df['sh000001'] = sh0000001_df['OPEN']
    df['sh000010'] = sh0000010_df['OPEN']

    df = df.fillna(method='bfill')

    print(df)